﻿using Shinva.LADModel.Models;
using Shinva.Variables.Models;
using Shinva.Variables.Type.combination;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Xml.Linq;

namespace Shinva.PLCModel.Models
{
   public  class PlcFC
    {
        #region 变量表快速访问属性

        //输入变量列表
        public PlcStruct InputStruct { get; set; } = new PlcStruct() { Name = "Input" };

        //输出变量列表
        public PlcStruct OutputStruct { get; set; } = new PlcStruct() { Name = "Output" };

        //可返回变量列表
        public PlcStruct InOutStruct { get; set; } = new PlcStruct() { Name = "InOut" };


        // 临时变量列表
        public PlcStruct TempStruct { get; set; } = new PlcStruct() { Name = "Temp" };

        // 常量列表
        public PlcStruct ConstantStruct { get; set; } = new PlcStruct() { Name = "Constant" };


        //返回列表
        public PlcStruct ReturnStruct { get; set; } = new PlcStruct() { Name = " Return" };

        #endregion



        /// <summary>
        /// 这是接口变量表
        /// </summary>
        public NormalVariableTable InterfaceVariableTable { get; set; } = new NormalVariableTable();

        /// <summary>
        /// 这是FB块中的梯形图了
        /// </summary>
        public Diagram LADTree { get; set; } = new Diagram();

        /// <summary>
        /// 程序名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 程序编号
        /// </summary>
        public int Number { get; set; }

        public PlcFC(ProgrammingLanguage language, int number, string name)
        {

            //构建变量表
            InterfaceVariableTable.AddMember(InputStruct);
            InterfaceVariableTable.AddMember(OutputStruct);
            InterfaceVariableTable.AddMember(InOutStruct);
            InterfaceVariableTable.AddMember(TempStruct);
            InterfaceVariableTable.AddMember(ConstantStruct);
            InterfaceVariableTable.AddMember(ReturnStruct);

            //构建程序信息
            Number = number;
            Name = name + "[" + "FC" + number + "]";
        }
    }
}
